# -*- encoding:utf-8 -*-
from mako import runtime, filters, cache
UNDEFINED = runtime.UNDEFINED
__M_dict_builtin = dict
__M_locals_builtin = locals
_magic_number = 5
_modified_time = 1287517883.5888309
_template_filename=u'/Users/joeldunham/old/onlinelinguisticdatabase/templates/base/formViews.html'
_template_uri=u'/base/formViews.html'
_template_cache=cache.Cache(__name__, _modified_time)
_source_encoding='utf-8'
from webhelpers.html import escape
_exports = ['formViewForHistory', 'dictionaryView', 'displaySecondaryData', 'formViewForAssociation', 'displayFormButtonsForMemory', 'displayAssociatedFiles', 'morphemesToLinks', 'formViewLong', 'displayPrimaryData', 'oneWordPerCell', 'alignWords', 'displayFormButtons', 'formViewForMemory']


# SOURCE LINE 1
import re 

def _mako_get_namespace(context, name):
    try:
        return context.namespaces[(__name__, name)]
    except KeyError:
        _mako_generate_namespaces(context)
        return context.namespaces[(__name__, name)]
def _mako_generate_namespaces(context):
    # SOURCE LINE 2
    ns = runtime.Namespace(u'markup', context._clean_inheritance_tokens(), templateuri=u'/base/markup.html', callables=None, calling_uri=_template_uri, module=None)
    context.namespaces[(__name__, u'markup')] = ns

    # SOURCE LINE 230
    ns = runtime.Namespace(u'fileViews', context._clean_inheritance_tokens(), templateuri=u'/base/fileViews.html', callables=None, calling_uri=_template_uri, module=None)
    context.namespaces[(__name__, u'fileViews')] = ns

def render_body(context,**pageargs):
    context.caller_stack._push_frame()
    try:
        __M_locals = __M_dict_builtin(pageargs=pageargs)
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        __M_writer = context.writer()
        # SOURCE LINE 1
        __M_writer(u'\n')
        # SOURCE LINE 2
        __M_writer(u'\n\n')
        # SOURCE LINE 11
        __M_writer(u'\n\n\n')
        # SOURCE LINE 18
        __M_writer(u'\n\n\n')
        # SOURCE LINE 25
        __M_writer(u'\n\n\n')
        # SOURCE LINE 30
        __M_writer(u'\n\n\n')
        # SOURCE LINE 52
        __M_writer(u'\n\n\n')
        # SOURCE LINE 85
        __M_writer(u'\n\n\n')
        # SOURCE LINE 101
        __M_writer(u'\n\n\n')
        # SOURCE LINE 151
        __M_writer(u'\n\n\n')
        # SOURCE LINE 205
        __M_writer(u'\n\n\n')
        # SOURCE LINE 217
        __M_writer(u'\n\n\n')
        # SOURCE LINE 226
        __M_writer(u'\n\n\n')
        # SOURCE LINE 248
        __M_writer(u'\n\n')
        # SOURCE LINE 270
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_formViewForHistory(context,form):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        self = _import_ns.get('self', context.get('self', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 21
        __M_writer(u'\n    ')
        # SOURCE LINE 22
        self.displayPrimaryData(form, True)
        
        __M_writer(u'\n    <hr />\n    ')
        # SOURCE LINE 24
        self.displaySecondaryData(form)
        
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_dictionaryView(context,form,languageToSortBy):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        url = _import_ns.get('url', context.get('url', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        c = _import_ns.get('c', context.get('c', UNDEFINED))
        gloss = _import_ns.get('gloss', context.get('gloss', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 250
        __M_writer(u'\n')
        # SOURCE LINE 251
        if c.languageToSortBy == 'ol':
            # SOURCE LINE 252
            __M_writer(u'          <div class="dictionaryEntry">\n            <p>\n              <a href="')
            # SOURCE LINE 254
            __M_writer(escape(url(controller='form', action='view', id=form.id)))
            __M_writer(u'" title="view more details about \'')
            __M_writer(escape(h.storageToOutputTranslate(form.transcription)))
            __M_writer(u"' (")
            __M_writer(escape(form.id))
            __M_writer(u')" class="dictionaryLink">\n                <span class="word">')
            # SOURCE LINE 255
            __M_writer(escape(h.storageToOutputTranslate(form.transcription)))
            __M_writer(u'</span>\n              </a>\n              <span class="meaning">')
            # SOURCE LINE 257
            __M_writer(escape(', '.join([gloss.gloss for gloss in form.glosses if not gloss.glossGrammaticality])))
            __M_writer(u'</span>\n            </p>\n          </div>\n')
            # SOURCE LINE 260
        elif c.languageToSortBy == 'ml':
            # SOURCE LINE 261
            __M_writer(u'          <div class="dictionaryEntry">\n            <p>\n              <a href="')
            # SOURCE LINE 263
            __M_writer(escape(url(controller='form', action='view', id=form.id)))
            __M_writer(u'" title="view more details about \'')
            __M_writer(escape(form.transcription))
            __M_writer(u"' (")
            __M_writer(escape(form.id))
            __M_writer(u')" class="dictionaryLink">\n                <span class="word">')
            # SOURCE LINE 264
            __M_writer(escape(form.transcription))
            __M_writer(u'</span>\n              </a>\n              <span class="meaning">')
            # SOURCE LINE 266
            __M_writer(escape(h.storageToOutputTranslate(form.gloss)))
            __M_writer(u'</span>\n            </p>\n          </div>\n')
            pass
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_displaySecondaryData(context,form,noID=True):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        url = _import_ns.get('url', context.get('url', UNDEFINED))
        capture = _import_ns.get('capture', context.get('capture', UNDEFINED))
        linkToOLDEntitites = _import_ns.get('linkToOLDEntitites', context.get('linkToOLDEntitites', UNDEFINED))
        keyword = _import_ns.get('keyword', context.get('keyword', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 154
        __M_writer(u'\n    <table class="formTable2">\n')
        # SOURCE LINE 156
        if form.comments:
            # SOURCE LINE 157
            __M_writer(u'    ')
            comments = h.literal(capture(linkToOLDEntitites, form.comments)) 
            
            __M_writer(u'    \n    <tr><td class="formTableRowLabel">comments</td><td class="dataCell">')
            # SOURCE LINE 158
            __M_writer(escape(h.storageToOutputTranslateOLOnly(comments)))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 160
        if form.speakerComments:    
            # SOURCE LINE 161
            __M_writer(u'    <tr><td class="formTableRowLabel">speaker comments</td><td class="dataCell">')
            __M_writer(escape(h.storageToOutputTranslateOLOnly(h.literal(form.speakerComments))))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 163
        if form.speaker:    
            # SOURCE LINE 164
            __M_writer(u'    <tr><td class="formTableRowLabel">speaker</td><td class="dataCell"><a href="')
            __M_writer(escape(url(controller='speaker', action='view', id=form.speaker.id)))
            __M_writer(u'" title="View more info about this speaker">')
            __M_writer(escape(form.speaker.firstName))
            __M_writer(u' ')
            __M_writer(escape(form.speaker.lastName))
            __M_writer(u' (')
            __M_writer(escape(form.speaker.dialect))
            __M_writer(u')</a></td></tr>\n')
            pass
        # SOURCE LINE 166
        if form.elicitor:
            # SOURCE LINE 167
            __M_writer(u'    <tr><td class="formTableRowLabel">elicitor</td><td class="dataCell"><a href="')
            __M_writer(escape(url(controller='researcher', action='view', id=form.elicitor.id)))
            __M_writer(u'" title="View more info about this researcher">')
            __M_writer(escape(form.elicitor.firstName))
            __M_writer(u' ')
            __M_writer(escape(form.elicitor.lastName))
            __M_writer(u'</a></td></tr>\n')
            pass
        # SOURCE LINE 169
        if form.source:
            # SOURCE LINE 170
            __M_writer(u'    <tr><td class="formTableRowLabel">source</td><td class="dataCell"><a href="')
            __M_writer(escape(url(controller='source', action='view', id=form.source.id)))
            __M_writer(u'" title="View more info about this source">')
            __M_writer(escape(form.source.authorLastName))
            __M_writer(u' (')
            __M_writer(escape(form.source.year))
            __M_writer(u')</a></td></tr>\n')
            pass
        # SOURCE LINE 172
        if form.enterer:
            # SOURCE LINE 173
            __M_writer(u'    <tr><td class="formTableRowLabel">enterer</td><td class="dataCell"><a href="')
            __M_writer(escape(url(controller='researcher', action='view', id=form.enterer.id)))
            __M_writer(u'" title="View more info about this researcher">')
            __M_writer(escape(form.enterer.firstName))
            __M_writer(u' ')
            __M_writer(escape(form.enterer.lastName))
            __M_writer(u'</a></td></tr>\n')
            pass
        # SOURCE LINE 175
        if form.verifier:
            # SOURCE LINE 176
            __M_writer(u'    <tr><td class="formTableRowLabel">verifier</td><td class="dataCell"><a href="')
            __M_writer(escape(url(controller='researcher', action='view', id=form.verifier.id)))
            __M_writer(u'" title="View more info about this researcher">')
            __M_writer(escape(form.verifier.firstName))
            __M_writer(u' ')
            __M_writer(escape(form.verifier.lastName))
            __M_writer(u'</a></td></tr>\n')
            pass
        # SOURCE LINE 178
        if form.dateElicited:
            # SOURCE LINE 179
            __M_writer(u'    <tr><td class="formTableRowLabel">date elicited</td><td class="dataCell">')
            __M_writer(escape(form.dateElicited.strftime('%b %d, %Y')))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 181
        if form.datetimeEntered:
            # SOURCE LINE 182
            __M_writer(u'    <tr><td class="formTableRowLabel">time entered</td><td class="dataCell">')
            __M_writer(escape(form.datetimeEntered.strftime('%b %d, %Y at %I:%M %p')))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 184
        if form.datetimeModified:
            # SOURCE LINE 185
            __M_writer(u'    <tr><td class="formTableRowLabel">last updated</td><td class="dataCell">')
            __M_writer(escape(form.datetimeModified.strftime('%b %d, %Y at %I:%M %p')))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 187
        if form.keywords:
            # SOURCE LINE 188
            __M_writer(u'    <tr><td class="formTableRowLabel">keywords</td><td class="dataCell">\n            ')
            # SOURCE LINE 189
            __M_writer(escape(', '.join([keyword.name for keyword in form.keywords])))
            __M_writer(u'\n    </td></tr>\n')
            pass
        # SOURCE LINE 192
        if form.syntacticCategory:
            # SOURCE LINE 193
            __M_writer(u'    <tr><td class="formTableRowLabel">category</td><td class="dataCell">')
            __M_writer(escape(form.syntacticCategory.name))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 195
        if form.syntacticCategoryString:
            # SOURCE LINE 196
            __M_writer(u'    <tr><td class="formTableRowLabel">category string</td><td class="dataCell">')
            __M_writer(escape(form.syntacticCategoryString))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 198
        if form.elicitationMethod:
            # SOURCE LINE 199
            __M_writer(u'    <tr><td class="formTableRowLabel">method</td><td class="dataCell">')
            __M_writer(escape(form.elicitationMethod.name))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 201
        if not noID:
            # SOURCE LINE 202
            __M_writer(u'    <tr><td class="formTableRowLabel">ID</td><td class="dataCell">')
            __M_writer(escape(form.id))
            __M_writer(u'</td></tr>\n')
            pass
        # SOURCE LINE 204
        __M_writer(u'    </table>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_formViewForAssociation(context,form):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        self = _import_ns.get('self', context.get('self', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 28
        __M_writer(u'\n    ')
        # SOURCE LINE 29
        self.displayPrimaryData(form, True)
        
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_displayFormButtonsForMemory(context,form):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        url = _import_ns.get('url', context.get('url', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 220
        __M_writer(u'\n  <div class="formButtonsDiv">\n    <a href="')
        # SOURCE LINE 222
        __M_writer(escape(url(controller='form', action='view', id=form.id)))
        __M_writer(u'" class="buttonLink" title="View more details about this Form"">view</a>\n    <a href="')
        # SOURCE LINE 223
        __M_writer(escape(url(controller='form', action='export', id=form.id)))
        __M_writer(u'" class="buttonLink" title="Export this Form to a variety of formats">export</a>\n    <a href="')
        # SOURCE LINE 224
        __M_writer(escape(url(controller='memory', action='forget', id=form.id)))
        __M_writer(u'" class="buttonLink" title="Remove this form from your Memory">forget</a>\n  </div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_displayAssociatedFiles(context,entity,entityType):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        url = _import_ns.get('url', context.get('url', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        app_globals = _import_ns.get('app_globals', context.get('app_globals', UNDEFINED))
        displayFile = _import_ns.get('displayFile', context.get('displayFile', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 229
        __M_writer(u'\n  ')
        # SOURCE LINE 230
        __M_writer(u'\n')
        # SOURCE LINE 231
        for file in entity.files:
            # SOURCE LINE 232
            if app_globals.allowedFileTypes[file.MIMEtype]:
                # SOURCE LINE 233
                __M_writer(u'      ')
                fileType = app_globals.allowedFileTypes[file.MIMEtype] 
                
                __M_writer(u'\n')
                # SOURCE LINE 234
            else: 
                # SOURCE LINE 235
                __M_writer(u'      ')
                fileType = file.MIMEtype.split('/')[0] 
                
                __M_writer(u'\n')
                pass
            # SOURCE LINE 237
            __M_writer(u'    <div class="associatedEntitiesDiv">\n     Associated File ')
            # SOURCE LINE 238
            __M_writer(escape(file.id))
            __M_writer(u': <span class="emphasize">')
            __M_writer(escape(file.name))
            __M_writer(u'</span> (')
            __M_writer(escape(h.pretty_filesize(file.size)))
            __M_writer(u')\n     <div class="containerDivIndent">\n      <a href="')
            # SOURCE LINE 240
            __M_writer(escape(url('disassociate', controller='%s'%entityType, id=entity.id, otherID=file.id)))
            __M_writer(u'" class="buttonLink" title=\'')
            __M_writer(escape("Click to disassociate %s %s from File %s"%(entityType.capitalize(), entity.id, file.id)))
            __M_writer(u'\'>disassociate</a> \n      <a href="')
            # SOURCE LINE 241
            __M_writer(escape(url(controller='file', action='view', id=file.id)))
            __M_writer(u'" class="buttonLink" title="')
            __M_writer(escape('Click to view more info about File %s' % file.id))
            __M_writer(u'">view</a>\n     </div>\n     <div class="containerDivIndent">\n      ')
            # SOURCE LINE 244
            __M_writer(escape(displayFile(file, fileType)))
            __M_writer(u'\n     </div>\n    </div>\n')
            pass
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_morphemesToLinks(context,word,lineType,form,subListIndex,wordIndex):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        url = _import_ns.get('url', context.get('url', UNDEFINED))
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        range = _import_ns.get('range', context.get('range', UNDEFINED))
        str = _import_ns.get('str', context.get('str', UNDEFINED))
        app_globals = _import_ns.get('app_globals', context.get('app_globals', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 104
        __M_writer(u'\n  ')
        # SOURCE LINE 111
        __M_writer(u'\n  ')
        # SOURCE LINE 112
    
        validDelimiters = app_globals.validDelimiters
        patt = '([%s])' % ''.join(validDelimiters)
        spacePatt = re.compile('([\t\n]| {2,})')
        morphemeBreakWords = spacePatt.sub(' ', form.morphemeBreak.strip()).split()
        morphemeGlossWords = spacePatt.sub(' ', form.morphemeGloss.strip()).split()
        morphemes = [len(re.split(patt, x)) for x in morphemeBreakWords]
        glosses = [len(re.split(patt, x)) for x in morphemeGlossWords]
        if morphemes == glosses:
            morphsAndDelimitersList = re.split(patt, word)
            mbIDsList = form.morphemeBreakIDsList[subListIndex][wordIndex]
            mgIDsList = form.morphemeGlossIDsList[subListIndex][wordIndex]
            madList = []
            for iii in range(len(morphsAndDelimitersList)):
                el = morphsAndDelimitersList[iii]
                if el in morphsAndDelimitersList[::2]:
                    if lineType == 'morphemeBreak':
                        elIDsList = mbIDsList[iii / 2]
                        otherIDsList = mgIDsList[iii / 2]
                    else:
                        elIDsList = mgIDsList[iii / 2]
                        otherIDsList = mbIDsList[iii / 2]
                    if [triple[0] for triple in elIDsList] == [triple[0] for triple in otherIDsList]:
                        klass = 'match'
                    else:
                        klass = 'nonmatch'
                    if len(elIDsList) > 0:
                        id = ','.join([str(triple[0]) for triple in elIDsList])
                        URL = url(controller='form', action='view', id=id)
                        title = '; '.join(['%s (%s)' % (triple[1], triple[2] or 'NULL') for triple in elIDsList])
                        madList.append('<a class="%s" href="%s" title="%s">%s</a>' % (klass, URL, title, el))
                    else:
                        id = None
                        madList.append(el)
                else:
                    madList.append(el)
            word = ''.join(madList)
          
        
        # SOURCE LINE 149
        __M_writer(u'\n  ')
        # SOURCE LINE 150
        __M_writer(escape(h.literal(h.storageToOutputTranslate(word, True))))
        __M_writer(u'\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_formViewLong(context,form):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        self = _import_ns.get('self', context.get('self', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 4
        __M_writer(u'\n    ')
        # SOURCE LINE 5
        self.displayPrimaryData(form, True)
        
        __M_writer(u'\n    <hr />\n    ')
        # SOURCE LINE 7
        self.displaySecondaryData(form, False)
        
        __M_writer(u'\n    ')
        # SOURCE LINE 8
        self.displayAssociatedFiles(form, 'form')
        
        __M_writer(u'\n    ')
        # SOURCE LINE 9
        self.displayFormButtons(form)
        
        __M_writer(u'\n    <div class="tableSpacerDiv"></div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_displayPrimaryData(context,form,noID=False):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        self = _import_ns.get('self', context.get('self', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 33
        __M_writer(u'\n')
        # SOURCE LINE 34
        if form.morphemeGloss and form.morphemeBreak and len(form.transcription.split(' ')) == len(form.morphemeGloss.split(' ')) and len(form.transcription.split(' ')) == len(form.morphemeBreak.split(' ')):
            # SOURCE LINE 35
            __M_writer(u'        ')
            self.alignWords(form, noID)
            
            __M_writer(u'\n')
            # SOURCE LINE 36
        else:
            # SOURCE LINE 37
            __M_writer(u'    <table class="formTable">\n')
            # SOURCE LINE 38
            if not noID:
                # SOURCE LINE 39
                __M_writer(u'    <tr><td class="formTableRowLabel">ID</td><td class="dataCell">')
                __M_writer(escape(form.id))
                __M_writer(u'</td></tr>\n')
                pass
            # SOURCE LINE 41
            __M_writer(u'    <tr><td class="formTableRowLabel">transcription</td><td class="dataCellTr">')
            __M_writer(escape(form.grammaticality))
            __M_writer(escape(h.storageToOutputTranslate(form.transcription)))
            __M_writer(u'</td></tr>\n    <tr><td class="formTableRowLabel">morpheme break</td><td class="dataCell">')
            # SOURCE LINE 42
            __M_writer(escape(h.storageToOutputTranslate(form.morphemeBreak, True)))
            __M_writer(u'</td></tr>\n    <tr><td class="formTableRowLabel">morpheme gloss</td><td class="dataCell">')
            # SOURCE LINE 43
            __M_writer(escape(form.morphemeGloss))
            __M_writer(u'</td></tr>\n')
            # SOURCE LINE 44
            for gloss in [gloss for gloss in form.glosses if not gloss.glossGrammaticality]:
                # SOURCE LINE 45
                __M_writer(u'        <tr><td class="formTableRowLabel">gloss</td><td class="dataCell">&lsquo;')
                __M_writer(escape(gloss.glossGrammaticality))
                __M_writer(escape(gloss.gloss))
                __M_writer(u'&rsquo;</td></tr>\n')
                pass
            # SOURCE LINE 47
            for gloss in [gloss for gloss in form.glosses if gloss.glossGrammaticality]:
                # SOURCE LINE 48
                __M_writer(u'        <tr><td class="formTableRowLabel">gloss</td><td class="dataCell">&lsquo;')
                __M_writer(escape(gloss.glossGrammaticality))
                __M_writer(escape(gloss.gloss))
                __M_writer(u'&rsquo;</td></tr>\n')
                pass
            pass
        # SOURCE LINE 51
        __M_writer(u'    </table>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_oneWordPerCell(context,wordList,lineType,form,subListIndex):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        h = _import_ns.get('h', context.get('h', UNDEFINED))
        range = _import_ns.get('range', context.get('range', UNDEFINED))
        self = _import_ns.get('self', context.get('self', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 88
        __M_writer(u' \n')
        # SOURCE LINE 89
        for ii in range(len(wordList)): 
            # SOURCE LINE 90
            __M_writer(u'        ')
 
            word = wordList[ii]
                    
            
            # SOURCE LINE 92
            __M_writer(u'\n')
            # SOURCE LINE 93
            if lineType == 'transcription' and ii == 0 and subListIndex == 0:
                # SOURCE LINE 94
                __M_writer(u'            <td class="dataCellTr">')
                __M_writer(escape(form.grammaticality))
                __M_writer(escape(h.storageToOutputTranslate(word)))
                __M_writer(u'</td>\n')
                # SOURCE LINE 95
            elif lineType == 'transcription':
                # SOURCE LINE 96
                __M_writer(u'            <td class="dataCellTr">')
                __M_writer(escape(h.storageToOutputTranslate(word)))
                __M_writer(u'</td>\n')
                # SOURCE LINE 97
            else: 
                # SOURCE LINE 98
                __M_writer(u'            <td class="dataCell">')
                __M_writer(escape(self.morphemesToLinks(word, lineType, form, subListIndex, ii)))
                __M_writer(u'</td>\n')
                pass
            pass
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_alignWords(context,form,noID=False):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        range = _import_ns.get('range', context.get('range', UNDEFINED))
        self = _import_ns.get('self', context.get('self', UNDEFINED))
        len = _import_ns.get('len', context.get('len', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 55
        __M_writer(u'\n ')
        # SOURCE LINE 59
        __M_writer(u'\n ')
        # SOURCE LINE 60
        form.listifyCoreData() 
        
        __M_writer(u'\n    <table class="formTable">\n')
        # SOURCE LINE 62
        if not noID:
            # SOURCE LINE 63
            __M_writer(u'    <tr><td class="formTableRowLabel">ID</td><td class="dataCell">')
            __M_writer(escape(form.id))
            __M_writer(u'</td></tr>\n    </table>\n')
            pass
        # SOURCE LINE 66
        for i in range(len(form.transcriptionList)):
            # SOURCE LINE 67
            __M_writer(u'     ')
            # SOURCE LINE 70
            __M_writer(u'\n     ')
            # SOURCE LINE 71
 
            styleAttribute = 'width: %sem;min-width: %sem; padding: 0;' % ((i * 2), (i * 2)) 
                 
            
            # SOURCE LINE 73
            __M_writer(u'  \n     <table class="formTable">\n        <tr><td class="formTableRowLabel">transcription</td><td style="')
            # SOURCE LINE 75
            __M_writer(escape(styleAttribute))
            __M_writer(u'"></td>')
            __M_writer(escape(self.oneWordPerCell(form.transcriptionList[i], 'transcription', form, i)))
            __M_writer(u'</tr>\n        <tr><td class="formTableRowLabel">morpheme break</td><td style="')
            # SOURCE LINE 76
            __M_writer(escape(styleAttribute))
            __M_writer(u'"></td>')
            __M_writer(escape(self.oneWordPerCell(form.morphemeBreakList[i], 'morphemeBreak', form, i)))
            __M_writer(u'</tr>\n        <tr><td class="formTableRowLabel" style="padding-bottom: 0.5em;">morpheme gloss</td><td style="')
            # SOURCE LINE 77
            __M_writer(escape(styleAttribute))
            __M_writer(u'"></td>')
            __M_writer(escape(self.oneWordPerCell(form.morphemeGlossList[i], 'morphemeGloss', form, i)))
            __M_writer(u'</tr>\n     </table>\n')
            pass
        # SOURCE LINE 80
        for gloss in form.glosses:
            # SOURCE LINE 81
            __M_writer(u'     <table class="formTable">\n        <tr><td class="formTableRowLabel">gloss</td><td class="dataCell">&lsquo;')
            # SOURCE LINE 82
            __M_writer(escape(gloss.glossGrammaticality))
            __M_writer(escape(gloss.gloss))
            __M_writer(u'&rsquo;</td></tr>\n')
            pass
        # SOURCE LINE 84
        __M_writer(u'     </table>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_displayFormButtons(context,form):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        url = _import_ns.get('url', context.get('url', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 208
        __M_writer(u'\n  <div class="formButtonsDiv">\n    <a href="')
        # SOURCE LINE 210
        __M_writer(escape(url(controller='form', action='update', id=form.id)))
        __M_writer(u'" class="buttonLink" title="Edit this Form\'s data">update</a>\n    <a href="')
        # SOURCE LINE 211
        __M_writer(escape(url(controller='form', action='delete', id=form.id)))
        __M_writer(u'" class="buttonLink" onclick="return confirmDelete(\'Form\', ')
        __M_writer(escape(form.id))
        __M_writer(u')" title="delete this Form; confirmation will be requested">delete</a>\n    <a href="')
        # SOURCE LINE 212
        __M_writer(escape(url(controller='form', action='history', id=form.id)))
        __M_writer(u'" class="buttonLink" title="View previous versions of this Form">history</a>\n    <a href="')
        # SOURCE LINE 213
        __M_writer(escape(url(controller='form', action='associate', id=form.id)))
        __M_writer(u'" class="buttonLink" title="Associate one or more Files to this Form">associate</a>\n    <a href="')
        # SOURCE LINE 214
        __M_writer(escape(url(controller='form', action='remember', id=form.id)))
        __M_writer(u'" class="buttonLink" title="Store a reference to this Form in your Memory">remember</a>\n    <a href="')
        # SOURCE LINE 215
        __M_writer(escape(url(controller='export', action='options', id='form%s' % form.id)))
        __M_writer(u'" class="buttonLink" title="Export this Form; you will be asked to choose a format">export</a>\n  </div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


def render_formViewForMemory(context,form):
    context.caller_stack._push_frame()
    try:
        _import_ns = {}
        _mako_get_namespace(context, u'markup')._populate(_import_ns, [u'linkToOLDEntitites'])
        _mako_get_namespace(context, u'fileViews')._populate(_import_ns, [u'displayFile'])
        self = _import_ns.get('self', context.get('self', UNDEFINED))
        __M_writer = context.writer()
        # SOURCE LINE 14
        __M_writer(u'\n    ')
        # SOURCE LINE 15
        self.displayPrimaryData(form)
        
        __M_writer(u'\n    ')
        # SOURCE LINE 16
        self.displayFormButtonsForMemory(form)
        
        __M_writer(u'\n    <div class="tableSpacerDivHalf"></div>\n')
        return ''
    finally:
        context.caller_stack._pop_frame()


